#include "QStandardPropertyFactory.h"

#include "QPropertyFactoryManager.h"

// Supported Properties
#include "QProperty.h"
#include "QBoolProperty.h"
#include "QColorProperty.h"
#include "QEmptyProperty.h"
#include "QEnumProperty.h"
#include "QFileProperty.h"
#include "QNumberProperty.h"
#include "QShortcutProperty.h"
#include "QVector3DProperty.h"


using namespace QPE;

QStandardPropertyFactory::QStandardPropertyFactory()
	: QAbstractPropertyFactory()
{
}

QStandardPropertyFactory::QStandardPropertyFactory(QPropertyFactoryManager *manager)
	: QAbstractPropertyFactory()
{
	if(manager) {
		manager->registerFactory("string", this);
		manager->registerFactory("bool", this);
		manager->registerFactory("color", this);
		manager->registerFactory("empty", this);
		manager->registerFactory("enum", this);
		manager->registerFactory("file", this);
		manager->registerFactory("integer", this);
		manager->registerFactory("double", this);
		manager->registerFactory("shortcut", this);
		manager->registerFactory("vector3d", this);
	}
}

QProperty *QStandardPropertyFactory::createProperty(const QString &type, const QString &name)
{
	if(type == QString("string")) {
		return new QProperty(name);
	} else if(type == QString("bool")) {
		return new QBoolProperty(name);
	} else if(type == QString("color")) {
		return new QColorProperty(name);
	} else if(type == QString("empty")) {
		return new QEmptyProperty(name);
	} else if(type == QString("enum")) {
		return new QEnumProperty(name);
	} else if(type == QString("file")) {
		return new QFileProperty(name);
	} else if(type == QString("integer")) {
		return new QIntegerProperty(name);
	} else if(type == QString("double")) {
		return new QDoubleProperty(name);
	} else if(type == QString("shortcut")) {
		return new QShortcutProperty(name);
	} else if(type == QString("vector3d")) {
		return new QVector3DProperty(name);
	}
	else
		return NULL;
}
